package km3;

import km2.StringHandlerDemo;

import java.util.Random;

public class RandomNumHandlerDemo {
    public static void main(String[] args) {
        useRandomNumHandler(new RandomNumHandler() {
            @Override
            public int getNumber() {
                Random x = new Random();
                int xam = x.nextInt(10)+1;
                return xam;
            }
        });
        // Lambda表达式
        useRandomNumHandler(()->{
            Random x = new Random();
            int xam = x.nextInt(100)-1;
            return xam;
        });


    }

    public static void useRandomNumHandler(RandomNumHandler x) {
        int xulei = x.getNumber();
        System.out.println(xulei);

    }
}
